package kItemsWithMaximumSum;

public class Solution {
    public int kItemsWithMaximumSum(int numOnes, int numZeros, int numNegOnes, int k) {
        // 优先取1 再取0 再取-1
        int res = 0;
        res+=Math.min(k,numOnes);  //相当于已经取了res个1的物体了；
        k-=res;
        k=Math.max(0,k-numZeros);
        res-=k;
        return res;
    }
}
